import mysql from 'mysql2'
import process from 'process'

const pool = mysql.createPool({
    host: "db",
    port: 3306,
    database: "wenku_wk",
    user: "wenku_wk",
    password: "wenku_wkwenku_wk",
    connectionLimit: 10, // 最大连接数
    queueLimit: 0, // 排队等待连接的最大请求数，0表示无限制
    waitForConnections: true // 当连接池达到最大连接数时，是否等待可用连接
});

process.on('exit', async (code) => {
    try { 
        pool.end() 
    } catch (e) {
        console.log(e);
     }
})


export { pool }